{template 'common/header-gw'}
<style>
    .account-rank img{width:20px; height:20px;}
    .alert{color:#666;padding:10px}
    .text-strong{font-size:14px;font-weight:bold;}
    .popover-content h5{padding-bottom: 5px}
</style>
<ol class="breadcrumb">
    <li><a href="./?refresh"><i class="fa fa-home"></i></a></li>
    <li><a href="{url 'system/welcome'}">系统</a></li>
    <li class="active">微站列表</li>
</ol>
<div class="clearfix" style="margin-bottom:5em;">
    {if !$_W['isfounder']}
    <div class="alert alert-warning">
        温馨提示：
        <i class="fa fa-info-circle"></i>
        Hi，<span class="text-strong">{$_W['username']}</span>，您所在的会员组 <span class="text-strong">{$stat['group_name']}</span>，
        账号有效期限：<span class="text-strong">{php echo date('Y-m-d', $_W['user']['starttime'])} ~~ {if empty($_W['user']['endtime'])}无限制{else}{php echo date('Y-m-d', $_W['user']['endtime'])}{/if}</span>，
        可添加 <span class="text-strong">{$stat['maxaccount']} </span>个微站，已添加<span class="text-strong"> {$stat['multiCount']} </span>个，还可添加 <span class="text-strong">{$stat['leftCount']} </span>个微站。
    </div>
    {/if}
    <div class="input-group">
        <a class="btn btn-primary" href="{php echo url('site/multi');}" style="margin-right: 10px"><i class="fa fa-plus"></i> 站点管理</a>
        <a class="btn btn-primary" href="{php echo url('account/weizhan/post');}" style="margin-right: 10px"><i class="fa fa-plus"></i> 添加微站</a>
        <a class="btn btn-primary" href="{url 'account/post-step'}"><i class="af fa-plus"></i> 添加公众号</a>
        {if $_W['setting']['platform']['authstate']}<a style="margin-left:5px;" href="{$authurl}"><img src="https://open.weixin.qq.com/zh_CN/htmledition/res/assets/res-design-download/icon_button3_2.png" /></a>{/if}
    </div>
    <br>
    <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <form action="./index.php" method="get" role="form" class="form-horizontal">
                <input type="hidden" name="c" value="account">
                <input type="hidden" name="a" value="display">
                <div class="form-group" style="margin-left: 40px">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">接入状态</label>
                    <div class="col-sm-8 col-lg-10 col-xs-12">
                        <div class="btn-group">
                            <a href="{php echo url('account/display', array('type' => '', 's_itemacid' => $_GPC['s_itemacid'], 'keyword' => $_GPC['keyword'], 'expiretime' => $_GPC['expiretime']));}"  class="btn {if $_GPC['type'] == ''}btn-primary{else}btn-default{/if}" style="width: 80px">全部</a>
                            <a href="{php echo url('account/display', array('type' => '1', 's_itemacid' => $_GPC['s_itemacid'], 'keyword' => $_GPC['keyword'], 'expiretime' => $_GPC['expiretime']));}"  class="btn {if $_GPC['type'] == '1'}btn-primary{else}btn-default{/if}">普通接入</a>
                            <a href="{php echo url('account/display', array('type' => '3', 's_itemacid' => $_GPC['s_itemacid'], 'keyword' => $_GPC['keyword'], 'expiretime' => $_GPC['expiretime']));}"  class="btn {if $_GPC['type']== '3'}btn-primary{else}btn-default{/if}">登录授权</a>
                        </div>
                    </div>
                </div>
                {if !empty($_W['isfounder'])}
                <div class="form-group" style="margin-left: 40px">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">过期时间</label>
                    <div class="col-sm-8 col-lg-10 col-xs-12">
                        <div class="btn-group">
                            <a href="{php echo url('account/display', array('type' => $_GPC['type'], 's_itemacid' => $_GPC['s_itemacid'], 'keyword' => $_GPC['keyword']));}"  class="btn {if $_GPC['expiretime'] == ''}btn-primary{else}btn-default{/if}" style="width: 80px">不限</a>
                            <a href="{php echo url('account/display', array('type' => $_GPC['type'], 's_itemacid' => $_GPC['s_itemacid'], 'keyword' => $_GPC['keyword'], 'expiretime' => '3'));}"  class="btn {if $_GPC['expiretime'] == '3'}btn-primary{else}btn-default{/if}" style="width: 80px">三天内</a>
                            <a href="{php echo url('account/display', array('type' => $_GPC['type'], 's_itemacid' => $_GPC['s_itemacid'], 'keyword' => $_GPC['keyword'], 'expiretime' => '7'));}"  class="btn {if $_GPC['expiretime'] == '7'}btn-primary{else}btn-default{/if}">一周内</a>
                            <a href="{php echo url('account/display', array('type' => $_GPC['type'], 's_itemacid' => $_GPC['s_itemacid'], 'keyword' => $_GPC['keyword'], 'expiretime' => '30'));}"  class="btn {if $_GPC['expiretime']== '30'}btn-primary{else}btn-default{/if}">一月内</a>
                        </div>
                    </div>
                </div>
                {/if}
                <div class="form-group" style="margin-top:20px;margin-left: 40px">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">搜索</label>
                    <div class="col-sm-8 col-lg-10 col-xs-12">
                        <div class="input-group">
                            <input type="hidden" name="type" value="{$_GPC['type']}">
                            <input type="hidden" name="expiretime" value="{$_GPC['expiretime']}">
                            <input type="text" class="form-control {if empty($_GPC['keyword']) && !empty($_GPC['s_itemacid'])}hide{/if}" placeholder="请输入微站名称" name="keyword" id="s_keyword" value="{$_GPC['keyword']}">
                            <input type="text" class="form-control {if empty($_GPC['s_itemacid'])}hide{/if}" placeholder="请输入微站ID" name="s_itemacid" id="s_itemacid" value="{$_GPC['s_itemacid']}">
                            <div class="input-group-btn">
                                <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                    <li><a href="javascript:;" onclick="$('#s_itemacid').addClass('hide').val('');$('#s_keyword').removeClass('hide');">根据微站名称搜索</a></li>
                                    <li><a href="javascript:;" onclick="$('#s_itemacid').removeClass('hide');$('#s_keyword').addClass('hide').val('');">根据微站ID搜索</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    {if $do == 'post'}
    <style>
        .template .item{position:relative;display:block;float:left;border:1px #ddd solid;border-radius:5px;background-color:#fff;padding:5px;width:190px;margin:0 20px 20px 0; overflow:hidden;}
        .template .title{margin:5px auto;line-height:2em;}
        .template .title a{text-decoration:none;}
        .template .item img{width:178px;height:270px; cursor:pointer;}
        .template .active.item-style img, .template .item-style:hover img{width:178px;height:270px;border:3px #009cd6 solid;padding:1px; }
        .template .title .fa{display:none}
        .template .active .fa.fa-check{display:inline-block;position:absolute;bottom:33px;right:6px;color:#FFF;background:#009CD6;padding:5px;font-size:14px;border-radius:0 0 6px 0;}
        .template .fa.fa-times{cursor:pointer;display:inline-block;position:absolute;top:10px;right:6px;color:#D9534F;background:#ffffff;padding:5px;font-size:14px;text-decoration:none;}
        .template .fa.fa-times:hover{color:red;}
        .template .item-bg{width:100%; height:342px; background:#000; position:absolute; z-index:1; opacity:0.5; margin:-5px 0 0 -5px;}
        .template .item-build-div1{position:absolute; z-index:2; margin:-5px 10px 0 5px; width:168px;}
        .template .item-build-div2{text-align:center; line-height:30px; padding-top:150px;}
        /*@media screen and (min-width:992px){#ListStyle{width:890px; margin:100px auto;}}*/
    </style>

    <form action="" method="post"  class="form-horizontal" role="form" enctype="multipart/form-data" >
        <div class="clearfix">
            <div class="panel panel-default">
                <div class="panel-heading">
                    站点信息
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">微站名称</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="text" name="title" class="form-control" value="{$multi['title']}" />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否启用</label>
                        <div class="col-sm-9 col-xs-12">
                            <label class="radio-inline"><input type="radio" name="status" value="1" {if $multi['status'] == '' || $multi['status'] == 1}checked{/if}>是</label>
                            <label class="radio-inline"><input type="radio" name="status" value="0" {if $multi['status'] === 0}checked{/if}>否</label>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">选择微站风格</label>
                        <div class="col-sm-8 col-xs-12">
                            <button type="button" class="btn btn-success" data-toggle="modal" data-target="#ListStyle">选择风格</button>
                            <input type="hidden" name="styleid" id="styleid" value="{$multi['styleid']}" />
                        </div>
                    </div>
                    <div class="form-group" id="preview-style" {if empty($multi['style']['tname'])}style="display:none;"{/if}>
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">当前微站风格</label>
                    <div class="col-sm-8 col-xs-12">
                        <div class="template">
                            <div class="item item-style">
                                <div class="title">
                                    <div style="overflow:hidden; height:28px;" id="current-title">{$multi['style']['name']}</div>
                                    <a href="javascript:;">
                                        <img src="{$_W['siteroot']}app/themes/{$multi['style']['tname']}/preview.jpg" id="current-preview" class="img-rounded">
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 风格列表 -->
                <div class="modal fade bs-example-modal-lg" id="ListStyle" aria-hidden="false" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                    <div class="modal-dialog modal-lg">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                                <h4 class="modal-title">微站模板风格列表</h4>
                            </div>
                            <div class="modal-body template clearfix">
                                {loop $styles $style}
                                <div class="item item-style {if $multi['styleid'] == $style['id']} active {/if}">
                                    <div class="title">
                                        <div class="title-{$style['id']}" style="overflow:hidden; height:28px;">{$style['name']}</div>
                                        <a href="javascript:;" class="change-style" data-styleid="{$style['id']}">
                                            <img src="{$_W['siteroot']}app/themes/{$style['tname']}/preview.jpg" class="img-rounded preview-{$style['id']}">
                                        </a>
                                        <span class="fa fa-check"></span>
                                    </div>
                                    <div class="btn-group  btn-group-justified">
                                        <a href="javascript:;" class="btn btn-default btn-xs change-style" data-styleid="{$style['id']}">选择风格</a>
                                    </div>
                                </div>
                                {/loop}
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">触发关键字</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="keyword" class="form-control" value="{$multi['site_info']['keyword']}" />
                        <div class="help-block">用户触发关键字，系统回复此页面的图文链接</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">头像</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="file" name="headimg">
                        <span class="help-block">只支持JPG图片</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                        <div class="input-group">
                            <img src="{php echo tomedia('headimg_'.$multi['id'].'.jpg')}?time={php echo time()}" class="img-responsive img-thumbnail" width="150" />
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">封面</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_image('thumb', $multi['site_info']['thumb'])}
                        <div class="help-block">用于用户触发关键字后，系统回复时的封面图片</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">页面描述</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="description" class="form-control" value="{$multi['site_info']['description']}" />
                        <div class="help-block">用户通过微信分享给朋友时,会自动显示页面描述</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">绑定域名</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="bindhost" class="form-control" value="{$multi['bindhost']}" />
                        <span class="help-block">绑定时请先将域名解析指向到本服务器，请只填写host部分，例如：www.baidu.com</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">底部自定义</label>
                    <div class="col-sm-9 col-xs-12">
                        <textarea style="height:150px;" class="form-control" cols="70" name="footer" autocomplete="off">{$multi['site_info']['footer']}</textarea>
                        <span class="help-block">自定义底部信息，支持HTML</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1" />
                <input type="hidden" name="token" value="{$_W['token']}" />
            </div>
        </div>
</div>
</form>

<script type="text/javascript">
    $('.change-style').click(function() {
        var styleId = parseInt($(this).data('styleid'));
        var title = $('.title-' + styleId).text();
        var preview = $('.preview-' + styleId).attr('src');
        $('.item-style').removeClass('active');
        $('#styleid').val(styleId);
        $('#current-title').text(title);
        $('#current-preview').attr('src', preview);
        $(this).parent().parent().addClass('active');
        $('#preview-style').show();
        $('#ListStyle').modal('hide');
    });
</script>
{elseif $do == 'display'}
<div class="clearfix template">
    {loop $multis $item}
    <div class="panel panel-default">
        <div class="panel-heading" style="height: 30px; line-height: 25px; padding: 0; padding-right: 10px; padding-left: 5px;">
            <div class="pull-right">
                <a href="javascript:;" data-url="{$_W['siteroot']}app/index.php?multiid={$item['id']}" class="js-clip" title="复制链接"><i class="fa fa-cog"></i>复制链接</a>&nbsp;&nbsp;
                <!--<a href="{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&j={$_W['acid']}" target="_blank" class="manage"><i class="fa fa-cog"></i>链接</a>-->

                <a href="{php echo url('weizhan/index', array('multiid' => $item['id']))}" target="_blank" class="manage"><i class="fa fa-cog"></i>管理微站</a>
            </div>
        </div>
        <div class="panel-body" style="line-height: 60px;">
            <div class="col-xs-12 col-sm-12 col-md-2 col-lg-1">
                <img src="{php echo tomedia('headimg_'.$item['id'].'.jpg');}?time={php echo time()}" class="" width="50" height="50"  onerror="this.src='resource/images/gw-wx.gif'" />
            </div>
            <div class="col-xs-12 col-sm-12 col-md-4 col-lg-5 item" style="font-size:16px;">
                {$item['title']}
            </div>
            <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 text-right">
                <!--<span style="width:80px; text-align:center; display:inline-block;">{if $item['isconnect'] == 1}<i class="fa fa-2x fa-check-circle text-success" style="position:absolute; top:15px;" data-toggle="tooltip" data-placement="top" title='接入状态 : {if $account['type'] == 3}登录授权{else}成功接入{/if}'></i>{$types[$account['type']]['title']}{else}<i class="fa fa-2x fa-times-circle text-warning" style="position:absolute; top:15px;" data-toggle="tooltip" data-placement="top" title='{if $account['type'] == 3}登录授权失败{else}公众号接入状态显示“未接入”解决方案：进入微信公众平台，依次选择: 开发者中心 -> 修改配置，然后将对应公众号在平台的url和token复制到微信公众平台对应的选项，公众平台会自动进行检测{/if}'></i>{$types[$account['type']]['title']}{/if}</span>-->
                <img src="../attachment/qrcode.png" class="" width="50" height="50" onclick="previewQRCode('{$item['url']}')" onerror="this.src='resource/images/gw-wx.gif'" />

            </div>
        </div>
        <div class="panel-footer" style="height:30px; padding: 0; padding-right: 10px; padding-left: 5px;">
            <div class="col-xs-6 text-right list-group-bottom-right pull-right">
                <a href="{php echo url('account/weizhan/enable', array('multiid' => $item['id']))}" class="btn" onclick="return confirm('{if $item['status'] == 1}禁止微站后，首页将不能访问，但数据依旧保存，确认吗？{else}确认开启微站吗？{/if}');return false;"><i class="fa fa-user"></i>{if $item['status'] == 1}禁止微站{else}开启微站{/if}</a>
                <a href="{php echo url('weizhan/operator', array('multiid' => $item['id']))}" class="btn"><i class="fa fa-user"></i>操作员管理</a>
                <a href="{php echo url('account/weizhan/post', array('multiid' => $item['id']))}" class="btn"><i class="fa fa-edit"></i>编辑</a>
                <a href="{php echo url('account/delete', array('multiid' => $item['id']))}" class="btn" onclick="return confirm('删除主公众号其所属的子公众号及其它数据会全部删除，确认吗？');return false;"><i class="fa fa-times"></i>删除</a>
            </div>
        </div>
    </div>
    {/loop}
</div>
<style>
    .template .dropdown{display:inline-block; cursor:pointer;}
    .template i{display:inline-block; width:15px; height:15px; font-size:15px; }
    .template .js-dropdown-menu span{display:inline-block; height:34px; line-height:34px; width:60px; text-align:center;}
    .template .dropdown-menu{margin:0;}
    .template .dropdown-menu i{width:20px; margin-right:10px; text-align:center;}
</style>
<script type="text/javascript">
    $(function(){
        $('.js-dropdown-menu').unbind('click');
        $('.js-dropdown-menu span').hover(function(){
            $(this).parent().addClass('open').find('.dropdown-menu').show();
            $(this).parent().find('.dropdown-menu').hover(function(){$(this).show();$(this).parent().addClass('open')},function(){$(this).hide();$(this).parent().removeClass('open');});
        },function(){
            $(this).parent().removeClass('open').find('.dropdown-menu').hide();
        });
    });
    function preview(styleid, $multiid) {
        var content = '<iframe width="320" scrolling="yes" height="480" frameborder="0" src="about:blank"></iframe>';
        var footer =
            '<a href="{url 'site/style/designer'}styleid=' + styleid + '" class="btn btn-primary">设计风格</a>' +
        '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>';
        var dialog = util.dialog('预览模板', content, footer);
        dialog.find('iframe').on('load', function(){
            $('a', this.contentWindow.document.body).each(function(){
                var href = $(this).attr('href');
                if(href && href[0] != '#') {
                    var arr = href.split(/#/g);
                    var url = arr[0];
                    if (url.substr(0, 3) == 'www') {
                        url = 'http://' + url;
                    }
                    if(arr[1]) {
                        url += ('#' + arr[1]);
                    }
                    if (url.substr(0, 10) == 'javascript') {
                        url = url.substr(0, url.lastIndexOf('&'));
                    }
                    $(this).attr('href', url);
                }
            });
        });
        var url = '../app/{php echo murl('home')}&s=' + styleid + '&multiid=' + $multiid;
        dialog.find('iframe').attr('src', url);
        dialog.find('.modal-dialog').css({'width': '322px'});
        dialog.find('.modal-body').css({'padding': '0', 'height': '480px'});
        dialog.modal('show');
    }
    function previewQRCode(value) {
        var content = '<iframe width="400" scrolling="yes" height="400" frameborder="0" src="about:blank"></iframe>';
        var dialog = util.dialog('二维码', content);
//        dialog.width = 100;
//        dialog.height = 100;
        var url = "../framework/library/qrcode/qrcode_png.php?value=" + value;
//        var url = '../attachment/qrcode_66.jpg';
        dialog.find('iframe').attr('src', url);
        dialog.find('.modal-dialog').css({'width': '250px'});
        dialog.find('.modal-body').css({'padding': '0', 'height': '250px'});
        dialog.modal('show');
    }
</script>
{/if}
{template 'common/footer'}